Skip to content

Add Cloud Run runtime guard alerts - #129

Merged
Pigbibi merged 1 commit into
mainfrom
codex/runtime-guard
Jun 2, 2026
Merged

Add Cloud Run runtime guard alerts#129
Pigbibi merged 1 commit into
mainfrom
codex/runtime-guard

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • add a Runtime Guard workflow that checks Cloud Scheduler and Cloud Run logs without invoking trading routes
  • send Telegram alerts directly for Cloud Scheduler, Cloud Run, or optional missed-run heartbeat issues
  • document setup and heartbeat behavior in English and Chinese

Validation

  • python -m py_compile scripts/cloud_run_runtime_guard.py
  • local dry run with scheduler check disabled
  • real read-only Cloud Logging smoke with Telegram disabled
  • git diff --check

@Pigbibi
Pigbibi merged commit 6636a15 into main Jun 2, 2026
1 check passed
@Pigbibi
Pigbibi deleted the codex/runtime-guard branch June 2, 2026 10:15

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50520dec7c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

issues.append(f"{len(failures)} Cloud Run failure log(s) for {service}")
details.extend(_summarize(entry) for entry in failures[:5])

if services and require_success and success_count == 0:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require a heartbeat per monitored service

When RUNTIME_GUARD_REQUIRE_SUCCESS=true and multiple Cloud Run services are configured, a success from any one service increments the shared success_count, so a slot/service with no requests in the lookback window is not reported as missed as long as another service ran. This defeats the missed-run heartbeat documented for slot deployments; track successes per service and alert for each configured service with zero successes.

Useful? React with 👍 / 👎.

Comment on lines +278 to +283
if not issues:
service_text = ", ".join(services) if services else "<none configured>"
print(
f"Runtime guard OK for {name}: services={service_text}, lookback={lookback_minutes}m, successes={success_count}"
)
return 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Fail when no Cloud Run services are configured

If none of RUNTIME_GUARD_CLOUD_RUN_SERVICES, CLOUD_RUN_SERVICES, CLOUD_RUN_SERVICE, or CLOUD_RUN_SERVICE_TARGETS_JSON is set, _load_services() returns an empty list and, with quiet Scheduler logs, this branch exits 0 with services=<none configured>. In that setup the guard never queries Cloud Run logs and silently misses all request/runtime failures, so the required service configuration should be treated as an alerting/configuration error unless scheduler-only mode is explicitly requested.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant